package jay.home.bet.web.struts;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jay.home.bet.domain.User;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import jay.home.bet.misc.Util;

public class ViewUserAction extends BaseAction
{
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception
	{
		ViewUserForm userForm = (ViewUserForm) form;
		String isonline = request.getParameter("false");
		String active = request.getParameter("true");
		String balance = request.getParameter("balance");
		String password = request.getParameter("password");
		System.out.println("execute");
		User user = getaccountService().getUser("zhangchao");
		isonline = "0";
		active = "0";
		if (isonline.equals(0))
		{
			isonline = "0";
			user.setOnline(true);
		} else
		{
			isonline = "1";
			user.setOnline(false);
		}

		if (active.equals(0))
		{
			active = "0";
			user.setActive(true);
		} else
		{
			active = "1";
			user.setActive(false);
		}
		user.setBalance(Util.toDouble(balance));
		user.setPassword(password);

		user.setOnline(false);
		user.setActive(true);
		getaccountService().updateUser(user);
		request.setAttribute("User", user);
		return mapping.findForward("SUCCESS");
	}
}
